<template>
  <div>
    <!-- 卡片 -->
    <van-card
    v-for="item in classifyList"
    :key="item.id"
    :price="item.price.toFixed(2)"
    :title="item.title"
    :thumb="item.img"
    desc="描述信息"
    >
      <template #footer>
        <van-button @click="addItem(item)" size="mini" type="info">+</van-button>
      </template>
    </van-card>
  </div>
</template>

<script>
import {mapState,mapActions,mapMutations} from 'vuex'
export default {
  created(){
    if(this.classifyList.length===0){
      this.init()
    }
  },
  computed:{
    ...mapState({
      classifyList:(state)=>state.Car.classifyList
    })
  },
  methods:{
    // 添加商品
    ...mapMutations({
      addItem:'Car/addItem'
    }),
    ...mapActions({
      init:'Car/init'
    })
  }
};
</script>

<style>
</style>